CubicWeb

The Semantic Web is a construction game!

Sandrine.Ribeau@logilab.fr

http://www.cubicweb.org

Evolution of the Web

The Semantic Web

=> need for adapted frameworks

CubicWeb: concepts

=> web apps AND semantic apps in one framework

CubicWeb: architecture

=> web apps AND semantic apps in one framework

Agility

=> agile and iterative development

Efficiency

=> efficient development and maintenance

Definition of a cube

class Blog(EntityType):
  title = String(maxsize=50, required=True)
  description = String()

class BlogEntry(EntityType):
  title = String(required=True, fulltextindexed=True)
  content = String(required=True, fulltextindexed=True)

class entry_of(RelationDefinition):
  subject = 'BlogEntry'
  object = 'Blog'

Assembling cubes

__use__ = ('blog', 'comment', 'tag',)

class comments(RelationDefinition):
    subject = 'Comment'
    object = 'BlogEntry'

class tags(RelationDefinition):
    subject = 'Tag'
    object = 'BlogEntry'

RQL queries (1/2)

Any X ORDERBY CD DESC LIMIT 10
WHERE X is BlogEntry, X creation_date CD

also UNION, EXISTS, sub-queries, optional variables (outer join), etc.

RQL queries (2/2)

Any X WHERE T tags X,
T name IN ('cubicweb', 'semantic'), X is BlogEntry

SELECT * FROM BlogEntryTable, TagTable, TagsRelationTable
WHERE BlogEntryTable.eid = TagsRelationTable.beid AND
      TagTable.name  IN ('cubicweb','semantic') AND
      TagTable.eid = TagsRelationTable.teid

View selection mechanism

A view is defined by:

When one want to use a view, it asks the registry to select the most suitable view of the given identifier according to a context.

Adapters and views (1/2)

For a better design and easier code reuse, views can use adapters to prevent incompatible interfaces.

class iCalView(EntityView):
    __select__ = adaptable('ICalendarable')

    # generate the iCal file to output

Adapters and views (2/2)

class BlogEntryICalendarableAdapter(EntityAdapter):
    __regid__ = 'ICalendarable'
    __select__ = is_instance('BlogEntry')

    @property
    def start(self):
        return self.entity.creation_date

    @property
    def stop(self):
        return self.entity.creation_date

Semantic views

=> publish data in RDF: LinkedData !

CubicWeb: history

CubicWeb: future

Using CubicWeb from TurboGears

class Root(controllers.RootController):

    cwdb = CubicWebDatabase('bookdb', 'admin', 'admin')

    @expose(template="cubictg.templates.welcome")
    def index(self, rql=''):
        rset, colnames = [], []
        if rql:
            rset = self.cwdb.execute(rql)
            colnames = get_col_names(rset)
        return dict(rql=rql, rset=rset, colnames=colnames)